import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collections;

/**
 * @author liyongkang16
 * @date 2022-07-17
 * @description
 */

public class GeneratorV2 {

    /**
     * 数据源配置
     */
    private static final DataSourceConfig.Builder DATA_SOURCE_CONFIG = new DataSourceConfig
        .Builder("jdbc:mysql://121.36.9.59:3307/lv_dev", "root", "kang");

    /**
     * 执行 run
     */
    public static void main(String[] args) throws SQLException {
        ge2();
    }

    private static void ge2(){
        FastAutoGenerator.create("jdbc:mysql://121.36.9.59:3307/lv_dev", "root", "kang")
            .globalConfig(builder -> {
                builder.author("iunti") // 设置作者
                    .enableSwagger() // 开启 swagger 模式
                    .fileOverride()
                    .outputDir("D://tmp//lv"); // 指定输出目录
            })
            .packageConfig(builder -> {
                builder.parent("com.iunti.lv.server") // 设置父包名
                    .moduleName("lv-server") // 设置父包模块名
                    .pathInfo(Collections.singletonMap(OutputFile.xml, "D://tmp//lv")); // 设置mapperXml生成路径
            })
            .strategyConfig(builder -> {
                builder.addInclude("lv_plan,lv_plan_subitem,lv_resource,lv_sell,lv_order,lv_collect,lv_follow,lv_clock_in") // 设置需要生成的表名
                    .addTablePrefix("lv_"); // 设置过滤表前缀
            })
            .execute();
    }


}